/*
board-games:	An educational framework for board games programming.
    Copyright (C) 2008  Daniel Gutson, FuDePAN
    
    This file is part of board-games.

    board-games is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    board-games is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
*/
#include "sudoku_internal.h"
#include "player_sdk/player.h"



class SudokuPlayer : public Player
{
    Board<SudokuNumber, BOARD_SIZE, BOARD_SIZE> board;
    PlayerAPI* const api;
    
        
    bool keep_playing()
    {
        bool ret;
        
        //first message is keep_playing:        
        api->receive_message_from_referee(ret);
        
        return ret;
    }

    virtual void play()
    {
        Sudoku_Move move;
        
        api->connect_board_with_referee(board);
        ::init_player(&board.get_board_memory());
        
        do
        {
            ::play(&move.row, &move.col, &move.number);
            api->send_message_to_referee(move);            
        }
        while(keep_playing());
    }
    
public:
    SudokuPlayer(PlayerAPI* api)
        : api(api), board(Empty_Cell)
    {}
};

Player* create_player(PlayerAPI* api)
{
    return new SudokuPlayer(api);
}

